/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkRtsp/MkRtspServer.h"
#include <MkUtil/MkLog.h>
#include "MkEvent/MkEventPool.h"
#include "MkEvent/MkTimer.h"
#include <signal.h>

const MkString TestPath = "/live/test";
int main(int argc, char** argv)
{
#ifdef _WIN32
    WSADATA WSAData;
    WSAStartup(0x101, &WSAData);
#else
    signal(SIGPIPE, SIG_IGN);  //ignore sigpipe
#endif
    MkLogInitLevel("TestTcpServer", TO_SCREEN);
    MkLogChangeLevel(LOG_DEBUG);
    //CMkEventPool *pPool = new CMkEventPool;
    //pPool->Start();
    //CMkTimer Timer;
    //CMkRtspServer *pServer = new CMkRtspServer(pPool,&Timer);
    //pServer->AddSource(TestPath);
    //CMkSdpMedia SdpMedia;
    //CMkSdpFmt SdpFmt(96, "H264", 90000);
    //char pbuf[10] = { 0 };
    //SdpFmt.SetBase64Sps("Z00AKY2NQDwBE/LCAAAOEAACvyAI");
    //SdpFmt.SetBase64Pps("aO44gA==");
    //SdpFmt.SetProfileLevelId(0x420029);
    //SdpFmt.SetH264PacketMode(1);
    //SdpMedia.SetCodec("video");
    //SdpMedia.SetPort(0);
    //SdpMedia.SetProtocol("RTP/AVP");
    //SdpMedia.SetConnection(CMkSdpConnection("IN", "IP4", "0.0.0.0"));
    //SdpMedia.SetBindWidth(CMkSdpBandWidth("AS", "5000"));
    //SdpMedia.SetControlUri("rtsp://192.168.101.5/live/test/track1");
    //SdpMedia.AddAttr(CMkSdpAttribute("recvonly",""));
    //SdpMedia.AddFmt(SdpFmt);
    ////pServer->AddSourceSdpMedia(TestPath, SdpMedia);
    //CMkSdpMedia SdpMedia2;
    //CMkSdpFmt SdpFmt2(104, "mpeg4-generic", 16000,1);
    //SdpFmt2.SetProfileLevelId(15);
    //SdpFmt2.SetFmtpNode("streamtype", "5");
    //SdpFmt2.SetFmtpNode("mode", "AAC-hbr");
    //SdpFmt2.SetFmtpNode("config", "1048");
    //SdpFmt2.SetFmtpNode("SizeLength", "13");
    //SdpFmt2.SetFmtpNode("IndexLength", "3");
    //SdpFmt2.SetFmtpNode("IndexDeltaLength", "3");
    //SdpFmt2.SetFmtpNode("Profile", "1");
    //SdpMedia2.SetCodec("audio");
    //SdpMedia2.SetPort(0);
    //SdpMedia2.SetProtocol("RTP/AVP");
    //SdpMedia2.SetConnection(CMkSdpConnection("IN", "IP4", "0.0.0.0"));
    //SdpMedia2.SetBindWidth(CMkSdpBandWidth("AS", "50"));
    //SdpMedia2.AddAttr(CMkSdpAttribute("recvonly",""));
    //SdpMedia2.AddAttr(CMkSdpAttribute("Media_header", "MEDIAINFO=494D4B48010300000400000101200110803E0000007D000000000000000000000000000000000000"));
    //SdpMedia2.AddFmt(SdpFmt2);
    //SdpMedia2.SetControlUri("rtsp://192.168.101.5/live/test/track2");
    //MkString tmpStr;
    //SdpMedia2.ToString(tmpStr);
    //pServer->AddAuthorate("admin", "admin");
    //pServer->SetRealm("rtsp server");
    //pServer->AddSourceSdpMedia(TestPath, SdpMedia2);
    //pServer->StartServer(554);
    while (1) {
        CMkThread::ThreadSleep(1);
    }
#ifdef _WIN32
    WSACleanup();
#endif
    return 0;
}


